package Utils.AutoCreateTable;

import Utils.PropertiesUtil;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

//import oracle.jdbc.driver.OracleDriver;

/**
 * @author tieyi  2019/12/21 23:03
 * @version 1.0.0
 * @Description: No Description
 * @package Utils.AutoCreateTable
 * @file Flink_UDF_Demo
 */
public class AuoToCTable {
    private Connection connection;
    private static String oracleUrl =  PropertiesUtil.getInstance().getValues("oracleUrl");
    private static String oracleUsername =  PropertiesUtil.getInstance().getValues("oracleUsername");
    private static String oraclePassword =  PropertiesUtil.getInstance().getValues("oraclePassword");
    private Statement statement;

    public void  init() throws Exception {
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");// 加载Oracle驱动程序,不用DriverManager
            connection =  DriverManager.getConnection(oracleUrl, oracleUsername, oraclePassword);;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public String CreateOracleTable(String sqlFileByte) throws SQLException {
            statement = connection.createStatement();
            boolean execute = statement.execute(sqlFileByte);
            if (!execute){
                return "SUCCESS";
            }
            return "Fail";
    }
}
